This invention relates to a pattern discriminator having a photoelectric converter of the two-dimensional sequential scanning type for scanning an optical image and for producing time based electrical signal outputs representing the scanned image, a binary converter circuit for dividing electrical signal into picture elements or pixels and for outputting the signals in the form of binary values, means for setting up at least one window region within an area corresponding to a field of vision of the photoelectric converter, and means for evaluating the binary outputs in each window region in order to recognize the pattern using the measured characteristic magnitudes.
FIG. 1 is a block diagram illustrating the configuration of a conventional pattern discriminator with a video camera. In FIG. 1, the pattern discriminator comprises a video camera 1, a binary converter 2, a window pattern generator 3, a binary data memory 4, a CPU (central processing unit) 5, a window pattern-setting assembly 6, and a television monitor 7.
During operation of this conventional device, composite video signals that the video camera has obtained by scanning a pattern are digitally processed by the binary converter 2 to obtain binary value data for picture elements (e.g. pixels). The data are taken out through an AND gate Al, which receives opening signals for only a fraction of the time interval as selected by the window output of the window pattern generator 3, and only the selected data in the window region are stored in the binary data memory 4. The data are then retrieved from the memory 4 and used to evaluate the pattern in CPU 5. Data from the binary converter 2 and the window output from the window pattern generator 3 are given to the television monitor 7 through an OR gate OR1. Therefore both the pattern and the window region previously set up for the pattern can be monitored.
FIG. 2 is a block diagram illustrating in more detail the conventional window pattern generator 3 heretofore employed in the pattern discriminator shown in FIG. 1, and consists of an X counter 15X, a Y counter 15Y, and comparators 16, 17. FIG. 3 is an explanatory view of the monitor television 7 shown in FIG. 1.
During operation of this conventional device, the counter 15X outputs an abscissa signal representing the abscissa scanning position on the screen 11 while counter Y outputs ordinate signals. Desired abscissas and ordinates have been previously set up in window-pattern-setting assemblies 6X and 6Y, respectively.
In the comparator 16, the output of the X counter 15X is compared with the preset value in the setting assembly 6X, and a horizontal window output signal 9 is produced only during a period of time that these two outputs conform to each other. In the comparator 17, the output of the Y counter 15Y is compared with the preset value in the setting assembly 6Y, and a vertical window output signal 10 is produced only during a period of time that these two outputs conform to each other. The window-generating signals 9 and 10 are inputted to an AND gate which generates a window output 12 representing a quadrilateral window region.
In examining patterns, it is very important to be able to set up a window region which limits the region under examination and to be able to generate window patterns having a variety of shapes. However, one of the disadvantages of the conventional methods of generating windows is that they have beem limited to quadrangles. The only method of producing other shaped windows having triangular, rhombic, polygonal, circular or other window patterns is to use PROM's (programmable read-only memories) which store the coordinates of the window pattern shapes in the setting assemblies 6X, 6Y shown in FIG. 2. However, this method is not flexible enough to produce windows of other shapes or dimensions.
FIG. 4 is a block diagram of a conventional pattern discriminator slightly different from what is shown in FIG. 1. In FIG. 4, the components shown include an analog-digital converter (A/D converter) 101, an image memory 102, a data collector 103, a decision processor 104, a selector 105, a setting assembly 106, and a multi-window region generator 107.
During operation of this device, an analog signal A from an iTV (industrial television) camera or other photoelectric converter of the two-dimensional sequential scanning type outputs time based electrical signals after scanning an optical image of a pattern being examined (not shown). These signals are given to the A/D converter 101 which includes a picture-element-dividing circuit (pixel divider), binary converter circuits and the like, which convert the signals into binary values according to a preset threshold level and divide the signal into picture elements (pixels) which are then stored in the image memory 102.
However, the analog signal that the iTV camera has obtained by scanning the optical image of the pattern being examined may fluctuate greatly depending on the degree of illumination of a particular region of the optical image and so on for binary conversion in the A/D converter 101. Therefore, use of the same threshold level for the whole region of the picture plane optical image may make it impossible to obtain a proper binary output. Accordingly, the analog signal is converted into several binary signals using different threshold levels, and each of the binary value signals is stored in the memory 102.
The multi-window generator 107 generates a signal which specifies a plurality of particular window regions to be specifically examined within the whole region of the picture plane optical image. Data selected by the selector 105 is received in the data collector 103 and, based on that selection, the window region (hereafter also referred to as simply a window) specified by the multi-window generator 107 is set up, and the outputs of data are produced by the collector 103 on a set window basis. The data generated is compared with reference data that has previously been inputted by the setting assembly 106 in the decision processor 104 and, based on the result of comparison, a decision output signal Y is produced.
In the conventional pattern discriminator thus constructed, the window region specified by the multi-window generator 107 is set up in a certain fixed location within the region corresponding to a field of vision of the iTV camera. For this reason, if the pattern being examined slips in the visual region, the window region will be improperly located and may result in an incorrect decision being made by using incorrect data. This problem will be described further in conjunction with FIGS. 5 and 6.
FIG. 5 is a plan view of the visual region of the iTV camera, showing an image of an object 111, a window 112, and a screen 113 of the iTV. In FIG. 5, it is assumed that the camera carries out horizontal scanning in the X direction. The signal obtained by the camera scanning the image of the object 111 on the horizontal scanning line having an ordinate Y1, is shown by FIG. 6(a). If the signal is converted into a digital or binary signal through a binary converter circuit like a comparator, it will become what is shown by FIG. 6(b). However, if the object 111 moves sideways and/or vertically in the X and/or Y direction, the output data obtained by scanning the inside of the fixed window 112 shown in FIG. 5 (for instance, N) may become too large or small, thus making it impossible to obtain reliable data on the characteristics of the image of object 111. Therefore, a decision after examination will likely be wrong or impossible to make.
One attempt to solve the shifting problem is by the use of reference points. A conventional method of determining reference locations in the optical image will be given with reference to FIG. 7, which is a plan view of a picture area 201 and an image 202 of an object. The location of image 201 within picture area 201 is represented by rectangular coordinates X and Y. Scanning by the camera is carried out in the horizontal (X) and vertical (Y) directions. The waveform of a photoelectric signal obtained by scanning the picture area along a straight line L on the ordinate Y1 is indicated in FIG. 8(a), and the binary output is shown by FIG. 8(b).
Referring now to FIG. 7, the location of the image 202 of the object in the picture area 201 can be represented by, for instance, a reference point S at the upper left corner of the image 202, provided that the shape of the image of the object is constant and known, and the ordinate and abscissa of the point S are obtainable.
Image processing techniques are often employed in inspection operations. For instance, suppose rectangular objects having the same shape as the one 202 shown in FIG. 7 are sequentially carried by a conveyer belt. A certain good object may be first scanned by an iTV camera and the results of the scan may be stored in a memory. Other objects carried by the conveyor can then be scanned, and by comparing the results of these other objects with those stored in the memory, one can determine whether certain characteristics of the subsequent objects are good or bad.
When such a comparison is made for inspecting purposes, if the location of the image of a subsequent object in the picture area shifts relative to the first scanned object a simple comparison may cause the subsequent object to be erroneously classified as a bad object. If the coordinates of the image reference point (S) 202 of an object shown in FIG. 7 are readily obtained in the image of an object subsequently sent in, one can effectively modify the location of the subsequent object using the coordinates so that a good comparison can be made. A comparison can be made as though the locations of two images in the picture area are the same, thus avoiding an erroneous decision.
In this context, one prior method for obtaining a certain reference location of an object within a picture area by carrying out horizontal and vertical scanning using an iTV camera to locate the point where the first image signal appears on the scanning line, and then by defining the abscissa X and the ordinate Y of this point as the coordinates of the reference point S. However, this prior art method has several disadvantages. In the first place, because the first or leading location is selected to be reference point S of the object image, if noise is contained in the signal, the location at which the noise appears may be wrongly judged the abscissa of the reference point S. As shown in FIG. 9, if an area of noise 203 in addition to the image 204 of the object is located in a picture area as shown in the figure, the ordinate Y1 and abscissa a.sub.1 (a.sub.1 being the abscissa of the tip of the noise 3) obtained by scanning the noise 203 may be misjudged the coordinates of the first point of the image.
Another disadvantage lies in the fact that, because the ordinate of the first point of the image is determined according to the discovered ordinate, an error in the ordinate may become greater depending on the shape of the image. In this context, as shown in FIG. 10, when the image 205 of an object has a complicated pincushion shape in the X direction in its upper portion, the abscissa of the point moves a significant distance from .tau.1 and .tau.2 even though the ordinate on the scanning line in the Y direction moves from Y1 to Y2 or by only one line. For this reason, for images of objects having such shapes, the error in the ordinate of the first point may be greater. Examples of objects having shapes which may present this type of problem include electrical connectors, ICs with projecting pins, and feathers. The disadvantage of making the error in the ordinate greater exists not only in the shape shown in FIG. 10 but also in a circularly shaped image 206. FIG. 11 illustrates that a change .DELTA.X in the abscissa direction amount is greater as compared to a change .DELTA.Y in the ordinate direction for such an object.
Generally speaking, it is very difficult to make the intensity of illumination within the vision of a camera (or a picture area to be picked up) uniform. Accordingly, depending on the location of the object's image within the region, some levels of the image signal may correspond to background or noise, and in these places it is difficult to detect an edge at the boundary between the image and its background. On the other hand, a portion where the level of the image signal often differs greatly from the background and the edge detection can be readily made. However, in the conventional method the abscissa of the first point of the image of the object is also used as the location for detecting its ordinate. Because this method lacks flexibility from a positioning standpoint, a further disadvantage is that the error becomes greater when the leading location is hard to detect.
One proposed apparatus for determining a reference location of an image in a picture area in order to improve the drawback just described is disclosed in Japanese Application No. 195671, 1981. According to this application, the coordinates of a reference point representing a reference location of an image of an object in terms of X and Y are not chosen to be the ordinate and abscissa coordinates of a single point in a picture area. Instead, the ordinate and abscissa of such a reference point are determined separately by selecting a location which minimizes error depending on the shape of the particular object. Moreover, the ordinate is determined only when the image signal level exceeds a preset first threshold level for a preset period during a period of scanning in the X direction. The abscissa is determined by selecting a location substantially free from an error where the detection of an edge can readily be made by using the abscissa of a leading location where the pickup signal begins to exceed a second threshold level and maintains that level during a period of scanning in the Y direction.
The description of the apparatus for determining the reference location of the image according to the proposal will be further given in conjunction with FIGS. 9-1 and 9-2. FIG. 9-2(a) illustrates a binary output waveform of a pickup signal obtained when scanning is carried out along the horizontal line L1 in FIG. 9-1 for the ordinate coordinate Y1. Similarly, FIG. 9-2(b) illustrates a binary output waveform of a pickup signal obtained when scanning is carried out along the horizontal line (including the point S, b3) along the ordinate coordinate Y2. Moreover, in FIG. 9-1, the first point S for obtaining the ordinate is determined as the point where the level of the pickup signal obtained by carrying out scanning along the horizontal scanning line which includes the point S exceeds the preset threshold level at least over the distance N. Thus, as shown in FIG. 9-2(a), this prevents a wrong decision regarding the noise 203 and the projections a2-b2 of the image as the first points. This method determines the ordinate.
Assuming the image 207 of the object has a shape shown in FIG. 12, the ordinate in the end region S1 may be easily determined as Ys by the use of the above method, but it is then difficult to obtain its abscissa. However, a look at the shape of the image 207 reveals that the abscissa remains constant against the fluctuation of the ordinate in the region S2 separated from the region S1 by ordinate distance Y.sub.S and that this abscissa may be obtained without errors. In the region S2, if the first point X.sub.1 obtained by horizontal scanning exceeds a preset threshold level is chosen as the reference abscissa, errors will be minimized. In addition, the threshold levels used to determine the ordinate and the abscissa are each determined depending on the actual condition of the signal level in each region. However, in practice, the coordinates can not always be properly determined using this method.